import java.awt.AlphaComposite;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Paint;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JPanel;
import java.awt.Dimension;
import javax.swing.JLabel;
import javax.swing.JProgressBar;
import java.awt.Color;
import java.awt.geom.RoundRectangle2D;

/**
 * Klasse Downloads
 * 
 * @author GUI-Programmer
 * @version 19.10.2011
 */
@SuppressWarnings("serial")
public class Downloads extends JDialog {

	protected JPanel contentPane;
	protected JLabel lblFileName;
	protected JProgressBar prgrsbr;
	protected RoundRectangle roundRectangle;

	public Downloads() {
		
		setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
		setTitle("Downloads");
		setResizable(false);
		
		contentPane = new JPanel() {
			@Override
		    protected void paintComponent(Graphics g) {
		        if (g instanceof Graphics2D) {
		            Paint p =
		                new GradientPaint(0.0f, 0.0f, new Color(0, 0, 140, 255),
		                    0.0f, getHeight(), new Color(100, 100, 230, 255), true);
		            Graphics2D g2d = (Graphics2D)g;
		            g2d.setPaint(p);
		            g2d.fillRect(0, 0, getWidth(), getHeight());
		        }
		    }
		};
		contentPane.setPreferredSize(new Dimension(420, 130));
		contentPane.setLayout(null);
		setContentPane(contentPane);
		
		prgrsbr = new JProgressBar();
		prgrsbr.setBounds(25, 37, 370, 25);
		contentPane.add(prgrsbr);
		
		lblFileName = new JLabel();
		lblFileName.setForeground(Color.YELLOW);
		lblFileName.setBounds(27, 70, 368, 22);
		contentPane.add(lblFileName);
		
		roundRectangle = new RoundRectangle();
		roundRectangle.setOpaque(false);
		roundRectangle.setBounds(15, 25, 390, 75);
		contentPane.add(roundRectangle);
		
		pack();
		setLocation(10, 10);
	}
	
	private class RoundRectangle extends JComponent {
		@Override
		protected void paintComponent(Graphics g) {
			if(g instanceof Graphics2D) {
				Graphics2D g2 = (Graphics2D) g;
				RoundRectangle2D.Double roundrectangle = new RoundRectangle2D.Double(0, 0, getWidth(), getHeight(), 10, 10);
				g2.setComposite(AlphaComposite.SrcOver);
				g2.setColor(new Color(255, 255, 255, 50));
				g2.fill(roundrectangle);
			}
		}
	}
}
